home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7802 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  970 b 

  1. Path: newsbf02.news.aol.com!not-for-mail
  2. From: razine@aol.com (Razine)
  3. Newsgroups: comp.lang.c++
  4. Subject: Question:Structures / Binary Files / Searching
  5. Date: 19 Feb 1996 00:31:35 -0500
  6. Organization: America Online, Inc. (1-800-827-6364)
  7. Sender: root@newsbf02.news.aol.com
  8. Message-ID: <4g91vn$f3k@newsbf02.news.aol.com>
  9. Reply-To: razine@aol.com (Razine)
  10. NNTP-Posting-Host: newsbf02.mail.aol.com
  11.  
  12. I currently have a Structure of 512 bytes.  I would like to search this
  13. file to match names.  I am seeing if there is a better way to do it then
  14. how I am doing it.  This is how I am doing it right now.
  15.  
  16. open the file
  17. get the filelength
  18. divide the filelenght by the sizeof(userrec) to get number of records.
  19. then I lseek in 512 byte increments
  20. read in the first 30 bytes which contains the name
  21. then I strcmp them
  22. if they match I exit
  23. if it doesnt match I lseek to the next record and check
  24.  
  25. Is there a faster way?  Easier way?  let me know please what you think...
  26.  
  27. Darrell
  28.